//==============================================================================
#ifndef _TEXTBOX_H_
#define _TEXTBOX_H_

#pragma once
#include "Component.h"
#include "SDL.h"
#include "SDL_draw.h"
#include "SDL_ttf.h"
#include "string"
#define FONT_SIZE 18;
//Space between last character rendered and end of textbox,
//values over or equal to 5 recommended.
#define END_SPACE 5
//Space between first character rendered and beginning of textbox,
//values over or equal to 5 recommended.
#define BEGIN_SPACE 5
//Colors
#define CYAN 0x99FFCC
#define BLACK 0x000000
#define WHITE 0xFFFFFF
#define ORANGE 0xFFCA12

//==============================================================================
namespace ui
{
class TextBox : public Component {
private:
	int posCursor;
	int fontSize;
	bool selected, active, cursor;
    std::string showText;

public:
	TextBox( int posX, int posY, int width, int height, COMPONENT_TYPE type, string name);
	TextBox( int posX, int posY, int width, int height, string defaultText, int fontSize);
	~TextBox(void);
	/**
	Renderizes the text.
	**/
	void drawText(SDL_Surface*) throw (SDL_Exception);

	/**
	According to the event received sets to show the character
	for the button pressed or gets active by getting clicked.
	**/
	COMPONENT_TYPE handleEvent(SDL_Event* event);

	/**
	Modifies value of selected attribute.
	**/
	void setSelected(bool select);
	/**
	Draws a blank box.
	**/
	void drawBox(SDL_Surface*) throw (SDL_Exception);
	/**
	Draws the textbox.
	**/
	void draw(SDL_Surface*) throw (SDL_Exception);
	/**
	Sets the text received as the content of the textbox.
	**/
	void setText(std::string t);
	/**
	Returns the textcontained in the textbox.
	**/
	string getText(void);

	string getType(void);

	/**
	Vacia la caja
	**/
	void clearBox();
	/**
	Draws cursor.
	**/
	void drawCursor(SDL_Surface*);
	/**
	Verifica que se hizo click en la caja.
	**/
	bool isClicked(SDL_Event* event);
	

	static const string TEXTBOX_TYPE;
};
};

#endif
//==============================================================================